package ch.fusun.baron.printing.command;

import ch.fusun.baron.core.command.GameCommand;
import ch.fusun.baron.core.injection.Inject;
import ch.fusun.baron.core.rmi.User;
import ch.fusun.baron.printing.MessagingService;

/**
 * Sends a message to everyone
 */
public class MessageCommand extends GameCommand {

	private User user;
	private String message;

	@Inject
	private transient MessagingService service;

	/**
	 * Kryo constructor
	 */
	public MessageCommand() {
	}

	/**
	 * @param user
	 *            The user
	 * @param message
	 *            The message
	 */
	public MessageCommand(User user, String message) {
		this.user = user;
		this.message = message;
	}

	@Override
	public boolean isAllowed() {
		return true;
	}

	@Override
	public void execute() {
		service.addMessage(user, message);
	}

}
